package com.own.component.common.base.service;

import com.own.component.common.base.entity.BaseBo;
import com.own.component.common.base.entity.BaseMap;
import com.own.component.common.base.entity.BaseQuery;
import com.own.component.common.base.entity.po.BaseBean;
import com.own.component.common.base.entity.vo.BaseBeanVo;
import com.own.component.common.model.UpdateModel;
import lombok.NonNull;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * BaseBindBeanService
 *
 * @author chenxueli
 * @version 1.0.0
 * @date 2022-06-15 03:14:15
 */
public interface BaseBindBeanService<
        PO extends BaseBean,
        BO extends BaseBo<PO>,
        VO extends BaseBeanVo<PO>,
        MAP extends BaseMap<PO>,
        QUERY extends BaseQuery>
        extends BaseService<PO, BO, VO, MAP, QUERY> {

    /**
     * 获取绑定的数据
     *
     * @param bean 绑定的对象
     * @return 绑定标识
     */
    PO getBindPo(@NonNull PO bean);

    /**
     * 单个数据绑定 （多个绑定键）
     *
     * @param bean 绑定的对象
     * @return 绑定标识
     */
    @Transactional(rollbackFor = Exception.class)
    UpdateModel<Boolean> bind(@NonNull PO bean);

    /**
     * 批量数据绑定
     *
     * @param bindIdList 绑定的id列表
     * @return 绑定标识
     */
    @Transactional(rollbackFor = Exception.class)
    UpdateModel<Boolean> bindBatch(@NonNull List<PO> bindIdList);

    /**
     * 单个数据解绑
     *
     * @param bean 解绑的对象
     * @return 解绑标识
     */
    @Transactional(rollbackFor = Exception.class)
    UpdateModel<Boolean> unbind(@NonNull PO bean);

    /**
     * 批量数据解绑
     *
     * @param unbindIdList 解绑的id列表
     * @return 解绑标识
     */
    @Transactional(rollbackFor = Exception.class)
    UpdateModel<Boolean> unbindBatch(@NonNull List<PO> unbindIdList);

}
